class ImError(BaseException):
    def __init__(self, code):
        self.errcode = code


SUCCESS = 200
TOO_MANY_CLIENTS = 300
TARGET_NOT_ONLINE = 301
UNKNOWN_COMMAND = 302
INVALID_USER = 303
LOGIN_REQUIRED = 400
USER_NOT_ONLINE = 401
USER_ONLINE_ALREADY = 402
CONNECTION_NOT_FOUND = 403
SERVER_ERROR = 500
SERVER_BUSY = 501

def get_error_message(errcode):
    return {
        SUCCESS: "成功",
        TOO_MANY_CLIENTS: "在线人数过多",
        TARGET_NOT_ONLINE: "目标用户不在线",
        UNKNOWN_COMMAND: "未知请求",
        INVALID_USER: "错误的用户名与密码",
        LOGIN_REQUIRED: "请登录",
        USER_NOT_ONLINE: "用户不在线",
        USER_ONLINE_ALREADY: "用户已在线",
    }[errcode]